/* Y o u r   D e s c r i p t i o n                       */
/*                            AppBuilder Photon Code Lib */
/*                                         Version 2.03  */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"

const short airplane_size=18;

typedef struct
{
	PhPoint_t center;
	char text[6];
} Airplane_Draw; 

void Draw_Airplanes(Airplane_Draw *ptr, int how_many);

void Radar_Raw( PtWidget_t *widget, PhTile_t *damage ) 
{
     Airplane_Draw planes[50];
    	PhPoint_t center = { 300 , 300 };
    	PhPoint_t radius = {285,285};
 	char Helvetica12[MAX_FONT_TAG];
 	int i,j, how_many;
 	
	PtSuperClassDraw( PtBasic, widget, damage );
	
	
	if(PfGenerateFontName("Helvetica", 0, 12, Helvetica12) == NULL) 
     	perror("Unable to find font");
     else 
		PgSetFont( Helvetica12 );


	// stworzenie testowej listy samolotow
	for(i=0; i<10; i++)
	{
		planes[i].center.x = i*45+30;
		planes[i].center.y = i*45+30;
		strcpy(planes[i].text, "555");
	}
	how_many = 10;
	
	Draw_Airplanes(planes, how_many);
	
}


void Draw_Airplanes(Airplane_Draw *ptr, int how_many)
{
	PhPoint_t radius = {340, 340};
	PhPoint_t center = {350,350};
	char text[5];
	int i=0;

	// narysowanie tarczy radaru
	PgSetFillColor(Pg_GREEN);
	PgDrawEllipse( &center, &radius, Pg_DRAW_FILL);

	//narysowanie samolotow	
	PgSetFillColor(Pg_YELLOW);
	PgSetTextColor( Pg_BLACK);
	
	while(i<how_many)
	{
			radius.x = airplane_size;
			radius.y = airplane_size;
			PgDrawEllipse( &(ptr->center) , &radius, Pg_DRAW_FILL);		
			PgDrawText( ptr->text, strlen(ptr->text), &center, 0);

			i++; 
	}
}	
